
// 二次封装axios
import axios from 'axios'

//创建axios的实例对象经行二次封装
const request = axios.create({
    baseURL: 'http://localhost:3000',
    // timeout: 5000
})
// request.defaults.headers.post['Content-Type'] = 'application/json'
//添加请求拦截器
request.interceptors.request.use(config => {
    //添加三个必须的请求头
    // config.headers['X-Requested-With'] = 'XMLHttpRequest'
    // config.headers['token'] = localStorage.getItem('token') || ''
    return config
})
//添加相应拦截器
request.interceptors.response.use(res => {
    return res.data
})
export default request